package org.autumn.jmm;

import java.util.concurrent.TimeUnit;

public class AlwaysRun {
    // 可见性问题 volatile
    private  static boolean run = true;
    public static void main(String[] args) throws InterruptedException {
        new Thread(() -> {
            while (run){
                // 这个线程不会停下来
            }
        }, "t1").start();


        TimeUnit.SECONDS.sleep(1);

        Thread t1 = new Thread(() -> {
            run = false;
        }, "t1");
        t1.start();

        t1.join();
        System.out.println(run);

    }
}
